{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "5abbe9f9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "bv: 49\n",
      "qaoa: 4950\n",
      "qft: 9900\n",
      "vqa: 4950\n"
     ]
    }
   ],
   "source": [
    "import qiskit\n",
    "import qiskit.qasm3\n",
    "from qiskit import QuantumCircuit\n",
    "for circuit_type in [\"bv\", \"qaoa\", \"qft\", \"vqa\"]:\n",
    "    c: QuantumCircuit = qiskit.qasm3.load(f\"circuits/{circuit_type}_100.qasm\")\n",
    "    count = 0\n",
    "    # 统计双比特门数量\n",
    "    for gate in c.data:\n",
    "        if (gate.operation.num_qubits == 2):\n",
    "            count += 1\n",
    "    print(f\"{circuit_type}:\", count)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "9301408a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "bv, 20: 9\n",
      "bv, 60: 29\n",
      "bv, 100: 49\n",
      "bv, 140: 69\n",
      "bv, 180: 89\n",
      "qaoa, 20: 190\n",
      "qaoa, 60: 1770\n",
      "qaoa, 100: 4950\n",
      "qaoa, 140: 9730\n",
      "qaoa, 180: 16110\n",
      "qft, 20: 380\n",
      "qft, 60: 3540\n",
      "qft, 100: 9900\n",
      "qft, 140: 19460\n",
      "qft, 180: 32220\n",
      "vqa, 20: 190\n",
      "vqa, 60: 1770\n",
      "vqa, 100: 4950\n",
      "vqa, 140: 9730\n",
      "vqa, 180: 16110\n"
     ]
    }
   ],
   "source": [
    "import qiskit\n",
    "import qiskit.qasm3\n",
    "from qiskit import QuantumCircuit\n",
    "for circuit_type in [\"bv\", \"qaoa\", \"qft\", \"vqa\"]:\n",
    "    for num in [20, 60, 100, 140, 180]:\n",
    "        c: QuantumCircuit = qiskit.qasm3.load(f\"circuits/{circuit_type}_{num}.qasm\")\n",
    "        count = 0\n",
    "        # 统计双比特门数量\n",
    "        for gate in c.data:\n",
    "            if (gate.operation.num_qubits == 2):\n",
    "                count += 1\n",
    "        print(f\"{circuit_type}, {num}:\", count)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "qiskit_env",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
